#ifndef XM_SOCKET_HH
#define XM_SOCKET_HH

#include "XM_noncopyable.hh"
#include "pch.hh"

XM_NAMESPACE_BEGIN

struct Socket : private XM_noncopyable
{
    explicit Socket(int sockfd)
        : sockfd__(sockfd)
    {}

    ~Socket();

    int fd() const { return sockfd__; }

    void bindAddr(const InetAddr& localAddr);

    void doListen();

    int accept(InetAddr* peerAddr);

    void shutdownWrite();

    void setTcpNoDelay(bool on);
    void setReuseAddr(bool on);
    void setReusePort(bool on);
    void setKeepAlive(bool on);

private:
    const int sockfd__;
};

XM_NAMESPACE_END

#endif // header file protect
